package cn.stylefeng.guns.sys.core.util;

import java.io.*;

public class ReadFile {
    public static void readTxtFile(String filePath) {
        //InfoBean infoBean=new InfoBean();
        try {
            String encoding = "GBK";
            File file = new File(filePath);
            if (file.isFile() && file.exists()) { //判断文件是否存在
                InputStreamReader read = new InputStreamReader(
                        new FileInputStream(file), encoding);//考虑到编码格式
                BufferedReader bufferedReader = new BufferedReader(read);
                String lineTxt = null;
                while ((lineTxt = bufferedReader.readLine()) != null) {
                    String[] s = lineTxt.split(",");
//                    infoBean.setLicense_num(s[0].toString());
//                    infoBean.setRecordtime(s[1].toString());
//                    infoBean.setSet_num(Integer.valueOf(s[2]));
//                    infoBean.setSpeed(Integer.valueOf(s[3]));
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static String readFileContent(String fileName) {
        File file = new File(fileName);
        BufferedReader reader = null;
        StringBuffer sbf = new StringBuffer();
        try {
            reader = new BufferedReader(new FileReader(file));
            String tempStr;
            while ((tempStr = reader.readLine()) != null) {
                sbf.append(tempStr);
            }
            reader.close();
            return sbf.toString();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
        return sbf.toString();
    }
}